<html>
<head><meta charset="utf-8"><title>Migrations · t-compiler/wg-rfc-2229 · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/index.html">t-compiler/wg-rfc-2229</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html">Migrations</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218185279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/218185279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#218185279">(Nov 28 2020 at 23:01)</a>:</h4>
<p>Created this issue with AssertUnwindSafe <a href="https://github.com/rust-lang/project-rfc-2229/issues/29">https://github.com/rust-lang/project-rfc-2229/issues/29</a></p>



<a name="218185401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/218185401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#218185401">(Nov 28 2020 at 23:05)</a>:</h4>
<p>This can be handled with the approach of adding <code>let wrapper = wrapper</code>, but I think this particular case could be good to keep track, or we might want to special case this and directly operate on the wrapper itself</p>



<a name="218805218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/218805218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#218805218">(Dec 04 2020 at 08:36)</a>:</h4>
<p>This might be a more common pattern than originally expected <a href="https://github.com/rust-lang/project-rfc-2229/issues/29#issuecomment-738631655">https://github.com/rust-lang/project-rfc-2229/issues/29#issuecomment-738631655</a></p>



<a name="219399917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219399917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219399917">(Dec 09 2020 at 21:22)</a>:</h4>
<p>really interesting</p>



<a name="219399938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219399938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219399938">(Dec 09 2020 at 21:22)</a>:</h4>
<p>I do wonder if <code>move</code> closures should just capture local variables</p>



<a name="219399972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219399972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219399972">(Dec 09 2020 at 21:23)</a>:</h4>
<p>since patterns like that seem to have no decent workaround to me</p>



<a name="219404543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219404543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219404543">(Dec 09 2020 at 21:56)</a>:</h4>
<p>Same, I was thinking maybe another keyword like <code>no_disjoint</code>, that is used similar to the move keyboard, just to be more explicit than having a difference in behaviors. </p>
<p>Though I'm not sure what the keyword should, or if should be adding a keyword</p>



<a name="219404634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219404634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219404634">(Dec 09 2020 at 21:57)</a>:</h4>
<p>I personally would prefer avoiding adding keywords to the language but I think it's a cleaner solution that let x = x patterns or having move closures not capture disjoint paths.</p>



<a name="219406142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219406142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219406142">(Dec 09 2020 at 22:08)</a>:</h4>
<p>so kind of like </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">no_disjoint</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">x</span><span class="p">;</span><span class="w">   </span><span class="c1">// p is captured here</span>
</code></pre></div>



<a name="219417948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219417948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219417948">(Dec 10 2020 at 00:11)</a>:</h4>
<p>It'll have to be discussed. I don't think <code>no_disjoint</code> is quite right :)</p>



<a name="219417957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219417957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219417957">(Dec 10 2020 at 00:11)</a>:</h4>
<p>but I might imagine something like explicit capture clauses</p>



<a name="219418603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219418603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219418603">(Dec 10 2020 at 00:20)</a>:</h4>
<p>Yeah, that was the first one that came to my mind. But yes, I think being explicit is probably the best way to avoid confusion</p>



<a name="219958224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219958224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219958224">(Dec 15 2020 at 10:12)</a>:</h4>
<p>Got initial migrations working for example:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(capture_disjoint_fields)]</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nb">String</span>::<span class="n">new</span><span class="p">(),</span><span class="w"> </span><span class="nb">String</span>::<span class="n">new</span><span class="p">());</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">t1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nb">String</span>::<span class="n">new</span><span class="p">(),</span><span class="w"> </span><span class="nb">String</span>::<span class="n">new</span><span class="p">());</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">t2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nb">String</span>::<span class="n">new</span><span class="p">(),</span><span class="w"> </span><span class="nb">String</span>::<span class="n">new</span><span class="p">());</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">_t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t</span><span class="p">.</span><span class="mi">0</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">_t1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t1</span><span class="p">.</span><span class="mi">0</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">_t2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t2</span><span class="p">.</span><span class="mi">0</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="n">c</span><span class="p">();</span><span class="w"></span>
</code></pre></div>
<p>That's the first one in the screenshot and the second one is similar but <code>String::new</code> -&gt; <code>0i32</code>, just to ensure <code>needs_drop</code> is working)<br>
<a href="user_uploads/4715/dgc1FnwswhN6AIM7Y4IcFI5H/image.png">image.png</a></p>
<div class="message_inline_image"><a href="user_uploads/4715/dgc1FnwswhN6AIM7Y4IcFI5H/image.png" title="image.png"><img src="user_uploads/4715/dgc1FnwswhN6AIM7Y4IcFI5H/image.png"></a></div>



<a name="219958374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219958374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219958374">(Dec 15 2020 at 10:13)</a>:</h4>
<p>From the initla implementation one thing that I didn't expect was this needed to be done post-writeback, <code>needs_drop</code> seems to rely on that. This means that we want to explictly visit closures because closures that don't capture anything because of only using wild cards will get missed if we just read closure_min_captures</p>



<a name="219961470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219961470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219961470">(Dec 15 2020 at 10:45)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> Hmm, interesting, I'm surprised that <code>needs_drop</code> requires it although I can imagine reasons it might be true</p>



<a name="219961529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219961529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219961529">(Dec 15 2020 at 10:46)</a>:</h4>
<p>We can <strong>probably</strong> refactor it</p>



<a name="219961533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219961533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219961533">(Dec 15 2020 at 10:46)</a>:</h4>
<p>Do you have some more details of what went wrong?</p>



<a name="219961540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219961540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219961540">(Dec 15 2020 at 10:46)</a>:</h4>
<p>Also, super exciting!</p>



<a name="219961553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219961553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219961553">(Dec 15 2020 at 10:46)</a>:</h4>
<p>well I think it needs the type to get folded than really writeback</p>



<a name="219961597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219961597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219961597">(Dec 15 2020 at 10:47)</a>:</h4>
<p>I haven't pushed a fix yet that does this during writeback</p>



<a name="219961601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219961601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219961601">(Dec 15 2020 at 10:47)</a>:</h4>
<p><a href="https://github.com/sexxi-goose/rust/pull/40">https://github.com/sexxi-goose/rust/pull/40</a></p>



<a name="219961618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219961618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219961618">(Dec 15 2020 at 10:47)</a>:</h4>
<p>but here were are my comments of what wasn't working</p>



<a name="219961812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/219961812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#219961812">(Dec 15 2020 at 10:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Migrations/near/219961553">said</a>:</p>
<blockquote>
<p>well I think it needs the type to get folded than really writeback</p>
</blockquote>
<p>this sounds likely</p>



<a name="220176790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/220176790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#220176790">(Dec 16 2020 at 21:41)</a>:</h4>
<p>What is the condition we want to trigger the migrations? </p>
<p>I'm currently doing feature and an env variable is set for testing</p>



<a name="220176825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/220176825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#220176825">(Dec 16 2020 at 21:41)</a>:</h4>
<p>I was thinking if the feature is set and the edition is 2018 for pushing to upstream</p>



<a name="220228957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/220228957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#220228957">(Dec 17 2020 at 10:53)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> the migration should be a lint and we should trigger based on whether the lint is enabled</p>



<a name="220229003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations/near/220229003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Migrations.html#220229003">(Dec 17 2020 at 10:54)</a>:</h4>
<p>you can test this from within the typeck code ...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>